<!--
 * @Author: your name
 * @Date: 2021-11-28 19:00:19
 * @LastEditTime: 2021-12-04 08:53:17
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /carbon/src/App.vue
-->
<template>
  <div class="app-container">
    <div class="header-wrapper" v-if="headerShow">
      <Header />
    </div>

    <router-view></router-view>
  </div>
</template>

<script>
import Header from "./components/Header.vue";
import {Notification} from "element-ui";

export default {
  components: {
    Header,
  },
  data(){
    return{
      headerShow:true
    }
  },
  created() {
    window.addEventListener("scroll", this.handlerScroll);
  },
  mounted() {
    this.TokenCenterJS.Init(add=>{
    })
    ethereum.on("accountsChanged", accounts => {
      this.TokenCenterJS.setMsgSender(accounts[0])
      Notification.success("您已切换账号,已重新加载页面")
      let rPath = this.$route.path.split('/',2)
      if(rPath[1] === "league"){
        this.$router.go(0);
      }
    });
  },
  destroyed() {
    window.removeEventListener("scroll", this.handlerScroll);
  },
  watch: {
    $route(to, from) {
      let rPath = this.$route.path.split('/',2)
      console.log(rPath[1])
      if(rPath[1] === "league"){
        this.headerShow = false;
      }
    }
  },
  methods: {
    handlerScroll() {
      this.$bus.$emit("handlerScroll", window.scrollY);
    },
  },
};
</script>

<style scoped lang="less">
</style>
